﻿using System.Collections;
using PublisherData;
using PublisherDomain;

namespace PublisherConsole;

class Program
{
    static void Main(string[] args)
    {
        var type = typeof(string);

        var comparer = Comparer<string>.Default;

        using (var pubContext = new PubContext())
        {
            pubContext.Database.EnsureCreated();
        }

        AddAuthor();
        GetAuthors();

    }





    static void GetAuthors()
    {
        using var pubContext = new PubContext();
        var pubContextAuthors = pubContext.Authors;
        var authors = pubContextAuthors.ToList();


        foreach (var author in authors)
        {
            Console.WriteLine(author.FirstName + " " + author.LaseName);
        }
        using var context = new PubContext();
        context.Database.EnsureCreated();
        
        Console.WriteLine("Hello, World!");
    }

    static void AddAuthorWithBook()
    {
        var pubContext = new PubContext();
        Author author = new Author();
        author.Books.Add(new Book()
        {
            Title = "C#",
            Price = 100,
            PublishDate = DateTime.Now,
        });
        pubContext.Add(author);




    }
    
    static void AddAuthor()
    {
        using var pubContext = new PubContext();
        var author = new Author()
        {
            FirstName = "feng",
            LaseName = "liulin",
        };
        pubContext.Authors.Add(author);
        pubContext.SaveChanges();
    }


    static void AddTest()
    {
        var pubContext = new PubContext();
        var authors = pubContext.Authors.ToList();
        foreach (var author in authors)
        {
            
        }
        
    }
}